
export const allBtns={

    btnEdit($this,h, params){
        return h('Button', {
            props: {type: 'primary', size: 'small'},
            style: {marginRight: '5px'},
            on: {
                click: () => {
                  switch ($this.current){
                    case 'couponsList':$this.$router.push({path: '/couponsSend',query:{id:$this.datas[params.index].id}});break;
                    case 'messageList':$this.$router.push({path: '/messageSend',query:{id:$this.datas[params.index].id}});break;
                  }
                }
            }
        }, '编辑')
    },
    btnInfo($this,h, params){
        return h('Button', {
            props: {type: 'info', size: 'small'},
            style: {marginRight: '5px'},
            on: {
                click: () => {
                    switch ($this.current){
                        case 'couponsList':$this.$router.push({path: '/couponsDetails',query:{id:$this.datas[params.index].id}});break;
                        case 'messageList':$this.$router.push({path: '/messageDetails',query:{id:$this.datas[params.index].id}});break;
                    }
                }
            }
        }, '详情')
    },
    btnDel($this,h, params){
        return h('Button', {
            props: {type: 'error', size: 'small'},
            style: {marginRight: '5px'},
            on: {
                click: () => {
                    $this.removeModal(params.index);
                }
            }
        }, '删除')
    },

    btnOff($this,h, params){  //下架
        return h('Button', {
            props: {type: $this.soldOutArr[params.index].typeColor, size: 'small',disabled:$this.soldOutArr[params.index].disabled},
            style: {marginRight: '5px'},
            on: {
                click: () => {
                    $this.couponOff(params.index);
                },

            }
        },$this.off )
    },

    btnPassed($this,h, params){
        return h('Button', {
           props: {type: $this.passArr[params.index].passColor, size: 'small',disabled:$this.passArr[params.index].disabled},
           style: {marginRight: '5px'},
            on: {
                click: () => {
                    $this.couponPass(params.index);
                },
            }
        },$this.passBtn)
    },



};



export const controlBtn={

    del($this,index){
        $this.modalDel=true;
        $this.delIndex=index;
        $this.content.id=$this.datas[index].id;            //id
        $this.content.name=$this.datas[index].name;        //名称-crontab holmes
        $this.content.type=$this.datas[index].type;        //certificate-类型
    },
    delSure($this,api,tipMsg){   //this, api.fun , tipMsg->提示xxx 删除成功

        api({data:{id:$this.content.id}})
            .then( response=>{
                if(response.rsp_head.rsp_code==200){
                    $this.modalDel=false;
                    $this.datas.splice($this.delIndex, 1);

                    $this.$Message.success( tipMsg +' 删除成功');
                }else{
                    $this.modalDel=false;
                    $this.$Message.error(response.rsp_head.rsp_info)
                }
            }).catch(error =>{
            console.log( error)
        })
    },
    delOff($this){
        $this.modalDel=false;
    },

    info($this,index){
        $this.modalInfo=true;

        //certificate
        $this.content.type      =$this.datas[index].type;
        $this.content.crt       =$this.datas[index].crt;
        $this.content.key       =$this.datas[index].key;
        $this.content.pem       =$this.datas[index].pem;
        $this.content.status    =$this.datas[index].status;
        $this.content.operator  =$this.datas[index].operator;
        $this.content.begin_date=$this.datas[index].begin_date;
        $this.content.end_date  =$this.datas[index].end_date;
        //holmes
        $this.content.id         =$this.datas[index].id;
        $this.content.name       =$this.datas[index].name;
        $this.content.description=$this.datas[index].description;
        $this.content.host       =$this.datas[index].host;
        $this.content.port       =$this.datas[index].port;
        $this.content.crt        =$this.datas[index].crt;
        $this.content.key        =$this.datas[index].key;

        //crontab
        $this.content.id    =$this.datas[index].id;
        $this.content.name  =$this.datas[index].name;
        $this.content.type  =$this.datas[index].type;
        $this.content.crond =$this.datas[index].crond;
        $this.content.value =$this.datas[index].value;
        $this.content.status=$this.datas[index].status;
    },
    infoSureOff($this){
        $this.modalInfo=false;
    }




};
